package locations.actions;

import javax.servlet.http.HttpServletRequest;

import locations.dao.DAOFactory;
import locations.dao.PacientDAO;
import locations.model.Pacient;

import org.apache.struts2.interceptor.ServletRequestAware;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class EditPacientAction extends ActionSupport implements
		ModelDriven<Pacient>, ServletRequestAware {

	private static final long serialVersionUID = -8124967730231198191L;

	private HttpServletRequest request;
	private Pacient pacient = new Pacient();

	public String execute() {
		Long id = Long.parseLong(this.getRequest().getParameter("id"));
		PacientDAO dao = DAOFactory.getPacientDAO();
		this.pacient = dao.retrieveById(id);
		return SUCCESS;
	}

	public Pacient getPacient() {
		return pacient;
	}

	public void setPacient(Pacient pacient) {
		this.pacient = pacient;
	}

	@Override
	public Pacient getModel() {
		return this.pacient;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;

	}
}